.TH std::ranges::stride_view::begin 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::stride_view::begin \- std::ranges::stride_view::begin

.SH Synopsis
   constexpr auto begin() requires (!__simple_view<V>);          \fB(1)\fP (since C++23)
   constexpr auto begin() const requires ranges::range<const V>; \fB(2)\fP (since C++23)

   Returns an iterator to the first element of the stride_view.

   1) Equivalent to return iterator<false>(this, ranges::begin(base_));.
   2) Equivalent to return iterator<true>(this, ranges::begin(base_));.

   Overload \fB(1)\fP does not participate in overload resolution if V is a simple view (that
   is, if V and const V are views with the same iterator and sentinel types).

.SH Parameters

   \fI(none)\fP

.SH Return value

   Iterator to the first element of the view.

.SH Example

   A link to test: Compiler Explorer.


// Run this code

 #include <print>
 #include <ranges>

 int main()
 {
     constexpr auto v = {'A', 'B', 'C'};
     const auto x = v | std::views::stride(2);
     const auto y = v | std::views::reverse | std::views::stride(2);
     const auto z = v | std::views::stride(2) | std::views::reverse;
     std::println("{} {} {}", *x.begin(), *y.begin(), *z.begin());
 }

.SH Output:

 A C C

.SH See also

   end     returns an iterator or a sentinel to the end
   (C++23) \fI(public member function)\fP
